package com.wilmer.bank_feedback.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.wilmer.common.annotation.Anonymous;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.wilmer.common.annotation.Log;
import com.wilmer.common.core.controller.BaseController;
import com.wilmer.common.core.domain.AjaxResult;
import com.wilmer.common.enums.BusinessType;
import com.wilmer.bank_feedback.domain.BankFeedback;
import com.wilmer.bank_feedback.service.IBankFeedbackService;
import com.wilmer.common.utils.poi.ExcelUtil;
import com.wilmer.common.core.page.TableDataInfo;

/**
 * 意见反馈Controller
 *
 * @author David
 * @date 2024-04-01
 */
@RestController
@Api(tags = "意见反馈接口")
@RequestMapping("/bank_feedback/feedback")
public class BankFeedbackController extends BaseController
{
    @Autowired
    private IBankFeedbackService bankFeedbackService;

    /**
     * 查询意见反馈列表
     */
    @ApiOperation("查询用户意见反馈，不允许匿名访问")
    @Anonymous
    @GetMapping("/list")
    public TableDataInfo list(BankFeedback bankFeedback)
    {
        startPage();
        List<BankFeedback> list = bankFeedbackService.selectBankFeedbackList(bankFeedback);
        return getDataTable(list);
    }

    /**
     * 导出意见反馈列表
     */
    @Log(title = "意见反馈", businessType = BusinessType.EXPORT)
    @Anonymous
    @PostMapping("/export")
    public void export(HttpServletResponse response, BankFeedback bankFeedback)
    {
        List<BankFeedback> list = bankFeedbackService.selectBankFeedbackList(bankFeedback);
        ExcelUtil<BankFeedback> util = new ExcelUtil<BankFeedback>(BankFeedback.class);
        util.exportExcel(response, list, "意见反馈数据");
    }

    /**
     * 获取意见反馈详细信息
     */
    @ApiOperation("获取意见详细信息")
    @GetMapping(value = "/{UserID}")
    @Anonymous
    public AjaxResult getInfo(@PathVariable("UserID") Long UserID)
    {
        return success(bankFeedbackService.selectBankFeedbackByUserID(UserID));
    }

    /**
     * 新增意见反馈
     */
    @Log(title = "意见反馈", businessType = BusinessType.INSERT)
    @PostMapping
    @Anonymous
    @ApiOperation("新增意见")
    public AjaxResult add(@RequestBody BankFeedback bankFeedback)
    {
        return toAjax(bankFeedbackService.insertBankFeedback(bankFeedback));
    }

    /**
     * 修改意见反馈
     */
    @Log(title = "意见反馈", businessType = BusinessType.UPDATE)
    @PutMapping
    @Anonymous
    @ApiOperation("修改意见")
    public AjaxResult edit(@RequestBody BankFeedback bankFeedback)
    {
        return toAjax(bankFeedbackService.updateBankFeedback(bankFeedback));
    }

    /**
     * 删除意见反馈
     */
    @Anonymous
    @ApiOperation("删除意见")
    @Log(title = "意见反馈", businessType = BusinessType.DELETE)
	@DeleteMapping("/{UserIDs}")
    public AjaxResult remove(@PathVariable Long[] UserIDs)
    {
        return toAjax(bankFeedbackService.deleteBankFeedbackByUserIDs(UserIDs));
    }
}
